/*
 * AbstractIdOLObject
 * 
 * Project: SSM
 * 
 * Copyright 2010 by HBASoft
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of HBASoft. ("Confidential Information"). You
 * shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license
 * agreements you entered into with HBASoft.
 */
package com.sunrise.xdoc.entity;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * This optimistic locking object has audit info: creationUser,
 * creationDateTime, modificationUser, modificationDateTime and version
 * 
 * @author phamcongbang
 * 
 */
@MappedSuperclass
public abstract class AbstractAuditEntity extends AbstractIdEntity {
	private static final long serialVersionUID = -4709212848984538326L;

	@Column(name = "creation_user", length = 16)
    @NotNull
	private String creationUser;

	@Column(name = "creation_date_time")
    @NotNull
	@Temporal(TemporalType.TIMESTAMP)
	private Date creationDateTime;

	@Column(name = "modification_user", length = 16)
    @NotNull
    private String modificationUser;

	@Column(name = "modification_date_time")
	@Temporal(TemporalType.TIMESTAMP)
    @NotNull
	private Date modificationDateTime;

	@Column(name = "version")
	private Long version;

	/**
	 * @return the userIdCreation
	 */
	public String getCreationUser() {
		return creationUser;
	}

	/**
	 * @param userIdCreation
	 *            the userIdCreation to set
	 */
	public void setCreationUser(String creationUser) {
		this.creationUser = creationUser;
	}

	/**
	 * @return the creationDate
	 */
	public Date getCreationDateTime() {
		return creationDateTime;
	}

	/**
	 * @param creationDate
	 *            the creationDate to set
	 */
	public void setCreationDateTime(Date creationDateTime) {
		this.creationDateTime = creationDateTime;
	}

	/**
	 * @return the userIdLastModification
	 */
	public String getModificationUser() {
		return modificationUser;
	}

	/**
	 * @param userIdLastModification
	 *            the userIdLastModification to set
	 */
	public void setModificationUser(String modificationUser) {
		this.modificationUser = modificationUser;
	}

	/**
	 * @return the lastModificationDate
	 */
	public Date getModificationDateTime() {
		return modificationDateTime;
	}

	/**
	 * @param lastModificationDate
	 *            the lastModificationDate to set
	 */
	public void setModificationDateTime(Date modificationDateTime) {
		this.modificationDateTime = modificationDateTime;
	}

    @Version
    public Long getVersion() {
		return version;
	}

	/**
	 * Only used by Hibernate.
	 * 
	 * @param version
	 */
	@Deprecated
	public void setVersion(Long version) {
		this.version = version;
	}
}
